/* this single file contains everything to implement the counter
   component in redux

the basic flow with redux is:
 - component calls an action,
 - action tells reducer what to do,
 - reducer changes the redux store */

export const initialState = {count: 0}

/* The action
  - component will call this to tell redux to increment the current count
  - returns the specific action the reducer will do, which is increment */
export const increment = () => ({type: 'INCREMENT'})

/* The reducer
  - gets called after an action is called
  - Takes the current state, and the action to do, and applies a transformation
    to the state

Note: this syntax might be a little strange to you, but it's basically
 a more functionaly switch-case */
export const reducer = (state=initialState, action) => (
  {'INCREMENT': {count: state.count + 1}
   // add more action types here
  } [action.type] || state
)
